from auto_trader import AutoTrader
from broker_api import BrokerAPI

from trading.strategy import MAStrategy # 初始化交易策略
strategy = MAStrategy()

# 初始化券商API
broker = BrokerAPI(
    api_key="你的API密钥",
    secret_key="你的密钥",
    account_id="你的账户ID"
)

# 交易标的列表
symbols = ['000001.SZ', '600000.SH', '600036.SH']

# 创建自动交易实例
trader = AutoTrader(
    broker_api=broker,
    strategy=strategy,
    symbols=symbols,
    initial_capital=100000,
    max_positions=5,
    position_size=0.2,
    stop_loss=0.02,
    take_profit=0.05
)

# 启动自动交易
trader.start()

# 运行一段时间后停止
# time.sleep(market_close_time - current_time)
# trader.stop()
